<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */
namespace App\Utils;

use Hyperf\Logger\LoggerFactory;
use Hyperf\Utils\ApplicationContext;

class Logger
{
    public static function getLogger(string $name = 'hyperf', string $group = 'default')
    {
        return ApplicationContext::getContainer()->get(LoggerFactory::class)->get($name, $group);
    }

    /**
     * 写日志.
     */
    public static function writeLog(string $msg, string $level = 'info', string $name = 'hyperf', string $group = 'default'): void
    {
        $logger = self::getLogger($name, $group);
        $logger->log($level, $msg);
    }
}
